export default {
  data() {
    return {
      bottom: '',
    };
  },
  methods: {
    // 切换加载更多的状态
    setLoadMoreStatus() {
      if (this.pageLoadMsg.noMore) {
        this.$refs.refresh.upWord = '已到达底部';
        this.bottom = 'height:0.64rem;margin-top:0.12rem';
        this.upPullEnable = false;
      } else if (this.pageLoadMsg.noData) {
        this.noData = true;
        this.upPullEnable = false;
        this.$refs.refresh.upWord = '';
        this.bottom = '';
      } else {
        this.upPullEnable = true;
      }
    },
    // 分页数据处理
    formatPagingData(data) {
      const { list, total, page_num, page_size } = data;
      if (total === 0) {
        //无数据
        this.pageLoadMsg.noData = true;
      } else if (page_size * page_num >= total) {
        // 已全部加载
        this.pageLoadMsg.noMore = true;
      } else {
        // donothing
      }
      // 正常数据处理
      if (page_num === 1) {
        this.dataList = list;
      } else {
        this.dataList = this.dataList.concat(list);
      }
      this.setLoadMoreStatus();
    },
  },
};
